package cn.zch.soft.util.number;
/***
 * @class MathUtils
 * @description TODO
 * @author zch
 * @date 2019/7/25
 * @version V0.0.1.201907251047.01
 * @function
 * @modfiyDate
 * @createDate
 * @package
 */
public class MathUtils {
	private final static StringBuilder ZERO = new StringBuilder("0");
	public static int getBitShift(int num, int shift) {
		int shifted = num << shift;
		// System.out.println(shifted);
		return shifted;
	}
	public static String getHexColor(int num, boolean withHex) {
		String hexStr = Integer.toHexString(num).toUpperCase();
		if (hexStr.length() < 2) {
			if (withHex) {
				return "0X" + "0" + hexStr;
			}
			else {
				return "0" + hexStr;
			}
		}
		else {
			if (withHex) {
				return "0X" + hexStr;
			}
			else {
				return hexStr;
			}
		}
	}
	public static String getExpectedLength(int num) {
		if (String.valueOf(num).length() < 2) {
			return ZERO.append(num).toString();
		}
		else {
			return String.valueOf(num);
		}
	}
	public static void main(String[] args) {
		System.out.println(getHexColor(1, false));
	}
}
